﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebBanHang
{
    public partial class main : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                loadDanhMucsp();
                if (CurrentContext.IsLogged)
                {
                    pnLogout.Visible = true;
                    pnLogout.Enabled = true;
                    hpUsername.Text = CurrentContext.UserName;
                    hpUsername0.NavigateUrl = "~/GUI/DonHang.aspx";
                }
                else
                {
                    PNLogin.Visible = true;
                    PNLogin.Enabled = true;
                }
            }
        }
        void loadDanhMucsp()
        {
            string sql = "select * from LoaiDeal";
            dlDanhMucsp.DataSource = DataProvider.LoadTable(sql);
            dlDanhMucsp.DataBind();
        }

        protected void btlogout_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            Response.Cookies["UserDangNhap"].Expires = DateTime.Now.AddDays(-1);
            Response.Redirect(Request.Url.ToString());
        }
    }
}